function crossover(rnvec1, rnvec2) {
  const len = rnvec1.length;
  let rnvec = new Array(len).fill(-1);
  for (let i = 0; i < len; i++) {
    if (Math.random() < 0.5) {
      for (let j = i; j < len; j++) {
        if (rnvec[j] === -1 && rnvec1[j] === rnvec1[i]) {
          rnvec[j] = rnvec1[i];
        }
      }
    } else {
      for (let j = i; j < len; j++) {
        if (rnvec[j] === -1 && rnvec2[j] === rnvec2[i]) {
          rnvec[j] = rnvec2[i];
        }
      }
    }
  }
  return rnvec;
}
export default crossover;
